/**
R(a,b,c,d,e);a,b->c;d,ep>c;b->d;toBCNF;
R(a,b,c,d,e);a,b->c;c->b;a->d;to3NF;
/**/
package hw03;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {		
		Schema schema = new Schema();
		
		Scanner statementScan = new Scanner(System.in);
		statementScan.useDelimiter(";");
		
		while(statementScan.hasNext()) {
			String statement = statementScan.next();
			
			MultivaluedDependency mvd = MultivaluedDependency.parse(statement, schema);
			if(mvd != null) {
				schema.getMultiValuedDependencies().add(mvd);
				System.out.println(mvd);
				continue;
			}

			FunctionalDependency fd = FunctionalDependency.parse(statement, schema);
			if(fd != null) {
				schema.getFunctionalDependencies().add(fd);
				System.out.println(fd);
				continue;
			}
			
			RelationalSignature rs = RelationalSignature.parse(statement, schema);
			if(rs != null) {
				schema.getRelationalSignatures().add(rs);
				System.out.println(rs);
				continue;
			}

			if(statement.contains("to3NF")) {
				schema.to3NF();
				System.out.println(schema);
				continue;
			}

			if(statement.contains("toBCNF")) {
				schema.toBCNF();
				System.out.println(schema);
				continue;
			}

			if(statement.contains("to4NF")) {
				schema.to4Nf();
				System.out.println(schema);
				continue;
			}
			
			if(statement.contains("toOrig")) {
				schema.toOrig();
				System.out.println(schema);
				continue;
			}
			
			if(statement.contains("show")) {
				System.out.println(schema);
				continue;
			}
			
			if(statement.contains("trace")) {
				Utils.trace = statement.contains("on");
				continue;
			}
		}
	}

}
